package com.heima.kafka.controller;

import com.alibaba.fastjson.JSON;
import org.springframework.kafka.annotation.KafkaListener;
import org.springframework.stereotype.Component;
import org.springframework.util.StringUtils;

import java.util.Map;

/**
 * 消费者
 */
@Component
public class HelloListener {

    @KafkaListener(topics = "itcast-topic")
    public void onMessage(String message){
        Map map = JSON.parseObject(message, Map.class);
        if(!StringUtils.isEmpty(message)){
            System.out.println(map.get("name"));
        }

    }
}